package cn.itcast.itcaststore.web.servlet.manager;

import cn.itcast.itcaststore.domain.Notice;
import cn.itcast.itcaststore.domain.Orders;
import cn.itcast.itcaststore.serive.NoticeService;
import cn.itcast.itcaststore.serive.OrderService;
import cn.itcast.itcaststore.serive.impl.NoticeServiceImpl;
import cn.itcast.itcaststore.serive.impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/admin/DeleteNoticeServlet")
public class DeleteNoticeServlet  extends HttpServlet {

    /**
     *
     *	后台删除公告的servlet
     */
        private static final long serialVersionUID = 1L;

        public void doGet(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {
            this.doPost(req, resp);
        }

        public void doPost(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {

            //获取要查询订单的id
            int noticeId = Integer.parseInt(req.getParameter("id"));
            //创建Service层对象,并根据id查询订单
           NoticeService nService = new NoticeServiceImpl();
            try {
                nService.deleteNotice(noticeId);
            } catch (SQLException e) {
                e.printStackTrace();
            }
            resp.sendRedirect(req.getContextPath() + "/admin/findNotice");




        }
}
